package com.cneport.das.server.api;

import com.cneport.das.common.utils.DateUtil;
import com.cneport.das.server.conf.ConfigCaches;
import com.cneport.das.server.trans.core.SecurityKeyService;
import com.cneport.das.server.trans.core.TransService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * @author GavinZhang
 * @version 1.0
 * @desc： 管理用的Controller
 * @company 东方物通科技有限（北京）公司
 * @date 2021/9/6 10:34
 */
@RestController
public class ManagerController {
    @Autowired
    private TransService serverService;
    @Autowired
    private SecurityKeyService securityKeyService;
    @Autowired
    private ConfigCaches configCaches;

    @GetMapping("/genKeyPair")
    public String genEncrptyKeys(@NotNull @RequestParam String path, @NotNull @RequestParam String senderId) {
        return securityKeyService.genEncryptKeyWithCorpNo(path, senderId);
    }

    @GetMapping("/freshConf")
    public String freshConf() {
        configCaches.parse();
        return "您于 " + DateUtil.now() + " 成功刷新DAS服务端配置!";
    }
}
